﻿<Window x:Class="W7StyleSample.MainWindow"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:Controls="clr-namespace:System.Windows.Controls;assembly=TreeViewEx"
      xmlns:Model="clr-namespace:W7StyleSample.Model"
      Title="MainWindow" Height="495"
      Width="550" AutomationProperties.Name="TestApp2Window">
   <Window.Resources>
      <HierarchicalDataTemplate ItemsSource="{Binding Children}" DataType="{x:Type Model:Node}">
         <TextBlock Text="{Binding Name}" />
      </HierarchicalDataTemplate>
   </Window.Resources>
   <StackPanel>
      <StackPanel Orientation="Horizontal">
         <TextBox x:Name="tb" Width="81" />
         <Controls:TreeViewEx x:Name="tree1" ItemsSource="{Binding Path=Children}" Height="105"
               Width="158" />
         <Button x:Name="button" Content="TestButton" />
         <TreeView x:Name="tree2" ItemsSource="{Binding Path=Children}" Height="102"
               Width="149" />
      </StackPanel>

      <Grid>
         <Grid.RowDefinitions>
            <RowDefinition />
            <RowDefinition />
            <RowDefinition />
            <RowDefinition />
            <RowDefinition />
            <RowDefinition />
            <RowDefinition />
            <RowDefinition />
            <RowDefinition />
            <RowDefinition />
            <RowDefinition />
            <RowDefinition />
         </Grid.RowDefinitions>
         <Grid.ColumnDefinitions>
            <ColumnDefinition />
            <ColumnDefinition />
         </Grid.ColumnDefinitions>

         <Label Margin="0,10,0,0">TextBox IsFocused:</Label>
         <Label Grid.Column="1" Margin="0,10,0,0">
            <Label.Style>
               <Style TargetType="Label">
                  <Setter Property="Content" Value="False" />
                  <Style.Triggers>
                     <DataTrigger Binding="{Binding IsFocused, ElementName=tb}" Value="True">
                        <Setter Property="Content" Value="True" />
                     </DataTrigger>
                  </Style.Triggers>
               </Style>
            </Label.Style>
         </Label>

         <Label Grid.Row="1">TextBox IsKeyboardFocused:</Label>
         <Label Grid.Row="1" Grid.Column="1">
            <Label.Style>
               <Style TargetType="Label">
                  <Setter Property="Content" Value="False" />
                  <Style.Triggers>
                     <DataTrigger Binding="{Binding IsKeyboardFocused, ElementName=tb}" Value="True">
                        <Setter Property="Content" Value="True" />
                     </DataTrigger>
                  </Style.Triggers>
               </Style>
            </Label.Style>
         </Label>

         <Label Grid.Row="2">TextBox IsKeyboardFocusWithin:</Label>
         <Label Grid.Row="2" Grid.Column="1">
            <Label.Style>
               <Style TargetType="Label">
                  <Setter Property="Content" Value="False" />
                  <Style.Triggers>
                     <DataTrigger Binding="{Binding IsKeyboardFocusWithin, ElementName=tb}"
                           Value="True">
                        <Setter Property="Content" Value="True" />
                     </DataTrigger>
                  </Style.Triggers>
               </Style>
            </Label.Style>
         </Label>
         

         <Label Grid.Row="3" Margin="0,10,0,0">TreeViewEx IsFocused:</Label>
         <Label Grid.Row="3" Grid.Column="1" Margin="0,10,0,0">
            <Label.Style>
               <Style TargetType="Label">
                  <Setter Property="Content" Value="False" />
                  <Style.Triggers>
                     <DataTrigger Binding="{Binding IsFocused, ElementName=tree1}" Value="True">
                        <Setter Property="Content" Value="True" />
                     </DataTrigger>
                  </Style.Triggers>
               </Style>
            </Label.Style>
         </Label>

         <Label Grid.Row="4">TreeViewEx IsKeyboardFocused:</Label>
         <Label Grid.Row="4" Grid.Column="1">
            <Label.Style>
               <Style TargetType="Label">
                  <Setter Property="Content" Value="False" />
                  <Style.Triggers>
                     <DataTrigger Binding="{Binding IsKeyboardFocused, ElementName=tree1}" Value="True">
                        <Setter Property="Content" Value="True" />
                     </DataTrigger>
                  </Style.Triggers>
               </Style>
            </Label.Style>
         </Label>

         <Label Grid.Row="5">TreeViewEx IsKeyboardFocusWithin:</Label>
         <Label Grid.Row="5" Grid.Column="1">
            <Label.Style>
               <Style TargetType="Label">
                  <Setter Property="Content" Value="False" />
                  <Style.Triggers>
                     <DataTrigger Binding="{Binding IsKeyboardFocusWithin, ElementName=tree1}"
                           Value="True">
                        <Setter Property="Content" Value="True" />
                     </DataTrigger>
                  </Style.Triggers>
               </Style>
            </Label.Style>
         </Label>
         

         <Label Grid.Row="6" Margin="0,10,0,0">Button IsFocused:</Label>
         <Label Grid.Row="6" Grid.Column="1" Margin="0,10,0,0">
            <Label.Style>
               <Style TargetType="Label">
                  <Setter Property="Content" Value="False" />
                  <Style.Triggers>
                     <DataTrigger Binding="{Binding IsFocused, ElementName=button}" Value="True">
                        <Setter Property="Content" Value="True" />
                     </DataTrigger>
                  </Style.Triggers>
               </Style>
            </Label.Style>
         </Label>

         <Label Grid.Row="7">Button IsKeyboardFocused:</Label>
         <Label Grid.Row="7" Grid.Column="1">
            <Label.Style>
               <Style TargetType="Label">
                  <Setter Property="Content" Value="False" />
                  <Style.Triggers>
                     <DataTrigger Binding="{Binding IsKeyboardFocused, ElementName=button}" Value="True">
                        <Setter Property="Content" Value="True" />
                     </DataTrigger>
                  </Style.Triggers>
               </Style>
            </Label.Style>
         </Label>

         <Label Grid.Row="8">Button IsKeyboardFocusWithin:</Label>
         <Label Grid.Row="8" Grid.Column="1">
            <Label.Style>
               <Style TargetType="Label">
                  <Setter Property="Content" Value="False" />
                  <Style.Triggers>
                     <DataTrigger Binding="{Binding IsKeyboardFocusWithin, ElementName=button}"
                           Value="True">
                        <Setter Property="Content" Value="True" />
                     </DataTrigger>
                  </Style.Triggers>
               </Style>
            </Label.Style>
         </Label>
         

         <Label Grid.Row="9" Margin="0,10,0,0">TreeView IsFocused:</Label>
         <Label Grid.Row="9" Grid.Column="1" Margin="0,10,0,0">
            <Label.Style>
               <Style TargetType="Label">
                  <Setter Property="Content" Value="False" />
                  <Style.Triggers>
                     <DataTrigger Binding="{Binding IsFocused, ElementName=tree2}" Value="True">
                        <Setter Property="Content" Value="True" />
                     </DataTrigger>
                  </Style.Triggers>
               </Style>
            </Label.Style>
         </Label>

         <Label Grid.Row="10">TreeView IsKeyboardFocused:</Label>
         <Label Grid.Row="10" Grid.Column="1">
            <Label.Style>
               <Style TargetType="Label">
                  <Setter Property="Content" Value="False" />
                  <Style.Triggers>
                     <DataTrigger Binding="{Binding IsKeyboardFocused, ElementName=tree2}" Value="True">
                        <Setter Property="Content" Value="True" />
                     </DataTrigger>
                  </Style.Triggers>
               </Style>
            </Label.Style>
         </Label>

         <Label Grid.Row="11">TreeView IsKeyboardFocusWithin:</Label>
         <Label Grid.Row="11" Grid.Column="1">
            <Label.Style>
               <Style TargetType="Label">
                  <Setter Property="Content" Value="False" />
                  <Style.Triggers>
                     <DataTrigger Binding="{Binding IsKeyboardFocusWithin, ElementName=tree2}"
                           Value="True">
                        <Setter Property="Content" Value="True" />
                     </DataTrigger>
                  </Style.Triggers>
               </Style>
            </Label.Style>
         </Label>
      </Grid>
   </StackPanel>
</Window>
